<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<!DOCTYPE html>
<html>
<head>
	<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0" /> 
	<title>page title</title>
	<meta name="keywords" content="">
    <meta name="description" content="">
	<!--[if lt IE 9]>
    	<script src="https://cdn.bootcss.com/html5shiv/r29/html5.min.js"></script>
    <![endif]-->
</head>
<body>
	<form:form method="POST" action="test/save" commandName="command">
		<form:input path="id" type="hidden"/>
		<form:input path="title" placeholder="标题"
				type="text" />
			<br />
			<form:select path="status">
				<form:option value="1">显示</form:option>
				<form:option value="0">隐藏</form:option>
			</form:select>
			<br />
			<button type="button" id="btnSave">保存</button>
	</form:form>
	
	<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.js"></script>
	<script>
		$(function(){
			$("#btnSave").click(function(){
				var data={"id":$("#id").val(),"title":$("#title").val(),"status":$("#status").val()};
				$.post($("form").attr("action"),data,function(result){
					if(result.flag){
						location.href='test';
					}else{
						alert(result.msg==null?"保存失败":result);
					}
				});
			});
		});
	</script>
</body>
</html>